<template>

  <view>
    <import src="/utils/wxparse/wxParse.wxml"></import>
    <block v-for="(item, index) in htmlParserTpl.nodes" :key="index">
      <template is="wxParse0" :data="item"></template>
    </block>
  </view>

</template>

<script>
import WxParse from '@/utils/wxparse/wxParse.js';

export default {
  data() {
    return {

        htmlParserTpl: {},
        bindData: {}

    };
  },

  async onLoad() {
    this.htmlParse();
  },

  mixins: [],
  components: {},
  props: {
    parserName: {
      type: String,
      default: 'htmlParserName'
    },
    parserContent: {
      type: String,
      default: '<p style=\'font-size: 32rpx; padding: 30rpx 0; text-align: center;\'>没有任何内容</p>'
    },
    parserType: {
      type: String,
      default: 'html'
    },
    parserPadding: {
      type: Number,
      default: 0
    }
  },
  methods: {
    htmlParserNotice() {
      this.htmlParse();
    },

    wxParseImgLoad(image) {
      let imgInfo = image.detail;
    },

    htmlParse() {
      /**
       * WxParse.wxParse(bindName , type, data, target,imagePadding)
       * 1.bindName绑定的数据名(必填)
       * 2.type可以为html或者md(必填)
       * 3.data为传入的具体数据(必填)
       * 4.target为Page对象,一般为this(必填)
       * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选)
       */
      try {
        let htmlContent = WxParse.wxParse(this.parserName, this.parserType, this.parserContent || this.props.parserContent.default, this, this.parserPadding);
        this.htmlParserTpl = htmlContent[this.parserName];
      } catch (e) {
        console.warn('kinerHtmlParser:', '没有任何内容需要转换', e);
      }
    },

    wxParseImgTap(e) {
      WxParse.wxParseImgTap(e, this.bindData);
    }

  },
  computed: {},
  watch: {}
};
</script>
<style lang="css" src="@/utils/wxparse/wxParse.wxss">

</style>